<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body>
  <div id="app">
    <common-head></common-head>
  </div>
  <script src="./vue.js"></script>
  <script>
    // 全局组件

    Vue.component('CommonHead', {
      template: `
        <div> 
          <h1>我是一个公共头部组件</h1>
          {{ msg }}
          <button @click="changeMsg">改变msg</button>
          <common-logo></common-logo>
          <input/>
        </div>
        >
      `,
      data(){
        return {
          msg: '你好组件'
        }
      },
      methods:{
        changeMsg(){
          this.msg = "哈哈我变了"
        }
      },
      components: {
        CommonLogo:{
          template:`
            <h2>我是一个子组件{{msg}}</h2>
          `,
          data(){
            return {
              msg: '我是子组件的数据'
            }
          }
        }
      }
    })
    const vm = new Vue({
      el: '#app',
      data:{
      
      }
      
    })
  </script>
</body>
</html>